package jeconbond.experiment.ui.reportage;

import java.util.ArrayList;
import java.util.List;

import javax.swing.JComponent;

import jeconbond.economic.natural.agent.service.ObserveResourceValueAgent;
import jeconbond.experiment.computation.DiagramUtils;
import jeconbond.experiment.natural.prodpossibfrontier.process.IConneryExperimentContext;
import jeconbond.experiment.natural.prodpossibfrontier.ConneryExperimentSettings;

import laboratoryQ.experiment.IExperimentResult;
import laboratoryQ.experiment.ui.reportage.BaseER2CConverter;
import laboratoryQ.flatness.DiagramData;
import laboratoryQ.flatness.Point;

public class ProductionPossibilityER2CConverter  extends BaseER2CConverter {
	public ProductionPossibilityER2CConverter(
			String experimentTitle
	) {
		super(
				experimentTitle,
				"Production possibility frointer"
		);
	}

	@Override
	public List<JComponent> convert2component(IExperimentResult expResult) {
		IConneryExperimentContext experimentContext =
			(IConneryExperimentContext) expResult;
		ConneryExperimentSettings settings = experimentContext.getExperimentSettings();
		ObserveResourceValueAgent orvAgent = experimentContext.getObserveResourceValueAgent();
		DiagramData d = new DiagramData();
		d.y = orvAgent.getLog(settings.tankResource);
		d.x = orvAgent.getLog(settings.traktorResource);
		DiagramUtils.substractPrev(d.x);
		DiagramUtils.substractPrev(d.y);
		d = DiagramUtils.fillZeros(d, new Point(0.0, 0.0));
		List<DiagramData> resultFirst = new ArrayList<DiagramData>();
		resultFirst.add(d);
		List<JComponent> result = new ArrayList<JComponent>();
		result.add(
				diagramList2componentStrategy.dia2component(resultFirst, "Traktors", "Tanks")	
		);
		return result;
	}
}
